﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TeachingAffairsManagementSystem.WebControl;

namespace TeachingAffairsManagementSystem.UserControl.RightContent.Student
{
    public partial class Info : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int s_id = Convert.ToInt32(Session["id"]);
            DataSet studentDataSet = Operation.QueryStudentByS_Id(s_id);
            string email = studentDataSet.Tables[0].Rows[0]["email"].ToString();
            string name = studentDataSet.Tables[0].Rows[0]["name"].ToString();
            char gender = Convert.ToChar(studentDataSet.Tables[0].Rows[0]["gender"]);
            TBEmail.Text = email;
            TBName.Text = name;
            if (gender == '男')
            {
                RMale.Checked = true;
            }
            else
            {
                RFemale.Checked = true;
            }
        }

        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            int s_id = Convert.ToInt32(Session["id"]);
            string name = TBName.Text;
            char gender = RMale.Checked ? '男' : '女';
            if (Operation.UpdateStudent(s_id, name, gender))
            {
                Alert.Show("修改成功", AlertBox.Level.Success, true);
            }
            else
            {
                Alert.Show("修改失败", AlertBox.Level.Danger, true);
            }
        }
    }
}